<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\SystemModel;

class SystemController extends Controller
{
    //首页
    public function index() {
        

        $systemModel = new SystemModel;

        $sys = $systemModel->getSys();

        return view('admin.system.index' , ['sys' => $sys]);
    }
    //修改页面
    public function edit() {

        $systemModel = new SystemModel;

        $sys = $systemModel->getSys();

        return view('admin.system.edit' , ['sys' => $sys]);
    }
    //修改
    public function update(Request $request) {
        //except() 去除数据里的_token 
        $data = $request->except('_token');

        $systemModel = new SystemModel;

        $res = $systemModel->upSys($data);

        if ($res) {
            return ['msg' => '修改成功' , 'status' => 'success'];
        } else {
            return ['msg' => '修改失败' , 'status' => 'fail'];
        }
    }
}
